package com.cyw.note.entity;

import com.cyw.note.vo.UserVo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author: Chenyw
 * @Date: 2022/08/22/14:42
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "note_index")
public class Note {

    @Id
    private String id;

    /**
     * 标题
     */
    @Field(name = "title", type = FieldType.Text, analyzer = "ik_max_word")
    private String title;

    /**
     * 内容
     */
    @Field(name = "content", type = FieldType.Text, analyzer = "ik_max_word")
    private String content;

    /**
     * 创建时间
     */
    @Field(name = "create_time", type = FieldType.Date, format = {}, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Field(name = "update_time", type = FieldType.Date, format = {}, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 描述
     */
    @Field(name = "description", type = FieldType.Text, analyzer = "ik_max_word")
    private String description;

    /**
     * 标签
     */
    @Field(name = "tags", type = FieldType.Keyword)
    private List<String> tags;

    /**
     * 首图
     */
    @Field(name = "first_picture", type = FieldType.Keyword)
    private String firstPicture;

    /**
     * 访问量
     */
    @Field(name = "views", type = FieldType.Integer)
    private Integer views;

    /**
     * 类型名
     */
    @Field(name = "type_name", type = FieldType.Text)
    private String typeName;

    /**
     * 评论数
     */
    @Field(name = "comment_count", type = FieldType.Integer)
    private Integer commentCount;

    /**
     * 用户
     */
    @Field(name = "user",type = FieldType.Object)
    private UserVo user;

}
